<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是说明在ubuntu中安装使用SSH的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV02-ubuntu-SSH的使用">
<meta property="og:url" content="https://sumumm.github.io/post/a3f1cf94.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是说明在ubuntu中安装使用SSH的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/download.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/download-1725146165641-3.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/download-1725146271625-6.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901072651457.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901072817928.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901072906728.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073005177.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074519334.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074537879.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/03105300c9e3eeccdee0b5ecf63dd86d.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074701252.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073543765.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073706572.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073934709.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074121752.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075230710.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074537879.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075434084.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075346249.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074519334.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075812169.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901080006762.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901080113043.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901080336783.png">
<meta property="article:published_time" content="2024-09-01T00:32:03.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.072Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="ubuntu">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/download.png">


<link rel="canonical" href="https://sumumm.github.io/post/a3f1cf94.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":"","permalink":"https://sumumm.github.io/post/a3f1cf94.html","path":"post/a3f1cf94.html","title":"LV02-ubuntu-SSH的使用"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV02-ubuntu-SSH的使用 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81SSH%E7%AE%80%E4%BB%8B"><span class="nav-text">一、SSH简介</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%AE%80%E4%BB%8B"><span class="nav-text">1. 简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81SSH%EF%BC%9F"><span class="nav-text">2. 为什么需要SSH？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-SSH%E6%98%AF%E5%A6%82%E4%BD%95%E5%B7%A5%E4%BD%9C%E7%9A%84%EF%BC%9F"><span class="nav-text">3. SSH是如何工作的？</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E8%BF%9E%E6%8E%A5%E5%BB%BA%E7%AB%8B"><span class="nav-text">3.1 连接建立</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E7%89%88%E6%9C%AC%E5%8D%8F%E5%95%86"><span class="nav-text">3.2 版本协商</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E7%AE%97%E6%B3%95%E5%8D%8F%E5%95%86"><span class="nav-text">3.3 算法协商</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E5%AF%86%E9%92%A5%E4%BA%A4%E6%8D%A2"><span class="nav-text">3.4 密钥交换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-5-%E7%94%A8%E6%88%B7%E8%AE%A4%E8%AF%81"><span class="nav-text">3.5 用户认证</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-6-%E4%BC%9A%E8%AF%9D%E8%AF%B7%E6%B1%82"><span class="nav-text">3.6 会话请求</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-7-%E4%BC%9A%E8%AF%9D%E4%BA%A4%E4%BA%92"><span class="nav-text">3.7 会话交互</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-SSH%E7%AB%AF%E5%8F%A3%E5%8F%B7%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="nav-text">4. SSH端口号是什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-ssh%E5%B7%A5%E5%85%B7"><span class="nav-text">5. ssh工具</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-SSH%E5%92%8CSSL%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="nav-text">6. SSH和SSL的区别</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81ubuntu%E4%B8%ADssh%E7%9A%84%E5%AE%89%E8%A3%85"><span class="nav-text">二、ubuntu中ssh的安装</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E6%A3%80%E6%9F%A5ssh%E6%98%AF%E5%90%A6%E5%B7%B2%E7%BB%8F%E5%AE%89%E8%A3%85"><span class="nav-text">1. 检查ssh是否已经安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%AE%89%E8%A3%85ssh%E6%9C%8D%E5%8A%A1"><span class="nav-text">2. 安装ssh服务</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-SSH%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4"><span class="nav-text">3. SSH相关命令</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81SSH%E6%9C%8D%E5%8A%A1%E7%9A%84%E5%BA%94%E7%94%A8"><span class="nav-text">三、SSH服务的应用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-VScode%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5ubuntu%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="nav-text">1. VScode远程连接ubuntu服务器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-Windows%E7%99%BB%E5%BD%95ubuntu%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="nav-text">2. Windows登录ubuntu服务器</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-ubuntu%E9%85%8D%E7%BD%AE"><span class="nav-text">2.1 ubuntu配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#2-1-1-NAT%E6%A8%A1%E5%BC%8F"><span class="nav-text">2.1.1 NAT模式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-1-2-%E6%A1%A5%E6%8E%A5%E6%A8%A1%E5%BC%8F"><span class="nav-text">2.1.2 桥接模式</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-Windows%E9%85%8D%E7%BD%AE"><span class="nav-text">2.2 Windows配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-1-windows%E5%90%AF%E5%8A%A8ssh%E6%9C%8D%E5%8A%A1"><span class="nav-text">2.2.1 windows启动ssh服务</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-2-%E4%B8%8Eubuntu%E7%9A%84ip%E4%BA%92ping"><span class="nav-text">2.2.2  与ubuntu的ip互ping</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-3-%E7%99%BB%E5%BD%95Ubuntu"><span class="nav-text">2.2.3 登录Ubuntu</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-3-MobaXterm%E7%99%BB%E5%BD%95ubuntu%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="nav-text">2.3 MobaXterm登录ubuntu服务器</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#2-3-1-%E6%9F%A5%E7%9C%8Bubuntu%E7%9A%84IP"><span class="nav-text">2.3.1 查看ubuntu的IP</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-3-2-%E8%BF%9E%E6%8E%A5ubuntu"><span class="nav-text">2.3.2 连接ubuntu</span></a></li></ol></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/a3f1cf94.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV02-ubuntu-SSH的使用 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV02-ubuntu-SSH的使用
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-09-01 08:32:03" itemprop="dateCreated datePublished" datetime="2024-09-01T08:32:03+08:00">2024-09-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/" itemprop="url" rel="index"><span itemprop="name">开发工具</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/" itemprop="url" rel="index"><span itemprop="name">04Ubuntu</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>5k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>18 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是说明在ubuntu中安装使用SSH的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" rowspan="5">PC端开发环境</td>        <td align="center" width=150px>Windows</td>        <td align="left">Windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu20.04.6的64位版本（一开始使用的是16.04版本，后来进行了升级）</td>      </tr>    <tr>        <td align="center">VMware® Workstation 17 Pro</td>        <td align="left">17.0.0 build-20800274</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>    </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr>    <tr>        <td align="center" rowspan="3">Linux开发板环境</td>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr><td align="center">参考资料  </td><td align="center">相关说明</td></tr>    <tr><td align="left">---</td><td align="left"><a href="" target="_blank">---<i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">---</td>        <td align="left">--- <a href="" target="_blank">  <i class="fa fa-external-link-alt"></i></a></td>      </tr></table>
              </div>
            </details>

<h1 id="一、SSH简介"><a href="#一、SSH简介" class="headerlink" title="一、SSH简介"></a><font size=3>一、SSH简介</font></h1><h2 id="1-简介"><a href="#1-简介" class="headerlink" title="1. 简介"></a><font size=3>1. 简介</font></h2><p>SSH，全称为Secure Shell，是一种网络协议，用于在不安全的网络中进行安全的数据传输和远程控制。通过加密和认证机制实现安全的访问和文件传输等业务。</p>
<p>传统远程登录和文件传输方式，例如Telnet、FTP，使用明文传输数据，存在很多的安全隐患。随着人们对网络安全的重视，这些方式已经慢慢不被接受。SSH协议通过对网络数据进行加密和验证，在不安全的网络环境中提供了安全的网络服务。作为Telnet和其他不安全远程shell协议的安全替代方案，目前SSH协议已经被全世界广泛使用，大多数设备都支持SSH功能。默认情况下，SSH服务器使用端口号22。</p>
<h2 id="2-为什么需要SSH？"><a href="#2-为什么需要SSH？" class="headerlink" title="2. 为什么需要SSH？"></a><font size=3>2. 为什么需要SSH？</font></h2><p>SSH代表什么？SSH 代表 Secure Shell，也称为 Secure Socket Shell。传统的互联网通信使用明文传输数据，内容一旦被截获就会完全暴露，存在很多安全隐患。SSH协议通过对网络数据进行加密和验证，建立SSH客户端和SSH服务器之间的安全隧道，在不安全的网络环境中为网络服务提供了安全的传输通道。</p>
<p>在SSH协议出现之前，Telnet广泛应用于远程登录场景，为远程管理网络设备提供了极大便利，而FTP作为常用的文件传输协议，兼具操作简单和传输效率高的优点，但它们都存在相同的问题，即明文传输数据带来的安全隐患。SSH采用加密传输数据、提升认证强度等手段，克服了Telnet和FTP应用中的安全性问题，实现了安全的远程登录和文件传输业务。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/download.png" alt="SSH常用场景" />

<h2 id="3-SSH是如何工作的？"><a href="#3-SSH是如何工作的？" class="headerlink" title="3. SSH是如何工作的？"></a><font size=3>3. SSH是如何工作的？</font></h2><p>SSH由服务器和客户端组成，为建立安全的SSH通道，双方需要先建立TCP连接，然后协商使用的版本号和各类算法，并生成相同的会话密钥用于后续的对称加密。在完成用户认证后，双方即可建立会话进行数据交互。SSH的工作流程包括如下几个阶段。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/download-1725146165641-3.png" alt="SSH工作流程" style="zoom:80%;" />

<h3 id="3-1-连接建立"><a href="#3-1-连接建立" class="headerlink" title="3.1 连接建立"></a><font size=3>3.1 连接建立</font></h3><p>SSH依赖端口进行通信。在未建立SSH连接时，SSH服务器会在指定端口侦听连接请求，SSH客户端向SSH服务器该指定端口发起连接请求后，双方建立一个TCP连接，后续会通过该端口通信。</p>
<h3 id="3-2-版本协商"><a href="#3-2-版本协商" class="headerlink" title="3.2 版本协商"></a><font size=3>3.2 版本协商</font></h3><p>SSH协议目前存在SSH1.X（SSH2.0之前的版本）和SSH2.0版本。SSH2.0协议相比SSH1.X协议来说，在结构上做了扩展，可以支持更多的认证方法和密钥交换方法，同时提高了服务能力。SSH服务器和客户端通过协商确定最终使用的SSH版本号，过程如下：</p>
<p>（1）SSH服务器通过建立好的连接向SSH客户端发送支持的SSH版本信息。</p>
<p>（2）SSH客户端收到版本信息后，根据自身支持的SSH版本决定使用的版本号，并将决定使用的版本号发送给SSH服务器。</p>
<p>（3）SSH服务器判断自己是否支持客户端决定使用的版本号，从而确定版本协商是否成功。</p>
<h3 id="3-3-算法协商"><a href="#3-3-算法协商" class="headerlink" title="3.3 算法协商"></a><font size=3>3.3 算法协商</font></h3><p>SSH工作过程中需要使用多种类型的算法，包括用于产生会话密钥的密钥交换算法、用于数据信息加密的对称加密算法、用于进行数字签名和认证的公钥算法和用于数据完整性保护的HMAC算法。SSH服务器和客户端对每种类型中具体算法的支持情况不同，因此双方需要协商确定每种类型中最终使用的算法，过程如下：</p>
<p>（1）SSH服务器和客户端分别向对方发送自己支持的算法。</p>
<p>（2）SSH服务器和客户端依次协商每种类型中具体使用的算法。在每类算法的协商过程中，SSH服务器和客户端都会匹配出双方均支持的算法作为最终使用的算法。每类算法均匹配成功后，算法协商完成。如果某类算法全部匹配失败，则该类型的算法协商失败，这会导致SSH服务器和客户端之间算法协商失败并断开连接。</p>
<h3 id="3-4-密钥交换"><a href="#3-4-密钥交换" class="headerlink" title="3.4 密钥交换"></a><font size=3>3.4 密钥交换</font></h3><p>SSH服务器和客户端通过密钥交换算法，动态生成共享的会话密钥和会话ID，建立加密通道。会话密钥主要用于后续数据传输的加密，会话ID用于在认证过程中标识该SSH连接。在该阶段也会完成客户端对服务器的身份认证，服务器先使用服务器私钥对消息进行签名，客户端再使用服务器公钥验证签名，从而完成客户端对服务器的身份认证。</p>
<p>由于SSH服务器和客户端需要持有相同的会话密钥用于后续的对称加密，为保证密钥交换的安全性，SSH使用一种安全的方式生成会话密钥，由SSH服务器和客户端共同生成会话密钥，利用数学理论巧妙地实现不直接传递密钥的密钥交换，无需通过不安全通道传送该密钥，具体过程如下图所示。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/download-1725146271625-6.png" alt="SSH密钥交换" />

<ol>
<li>SSH服务器生成素数G、P、服务器私钥b，并计算得到服务器公钥$y&#x3D;(G^b)%P$。</li>
<li>SSH服务器将素数G、P、服务器公钥y发送给SSH客户端。</li>
<li>SSH客户端生成客户端私钥a，计算得到客户端公钥$x&#x3D;(G^a)%P$。</li>
<li>SSH客户端将客户端公钥x发送给SSH服务器。</li>
<li>SSH服务器计算得到对称密钥$K&#x3D;(x^b) % P$，SSH客户端计算得到对称密钥$K&#x3D;(y^a)%P$，数学定律可以保证SSH服务器和SSH客户端生成的对称密钥相同。</li>
</ol>
<h3 id="3-5-用户认证"><a href="#3-5-用户认证" class="headerlink" title="3.5 用户认证"></a><font size=3>3.5 用户认证</font></h3><p>SSH客户端向SSH服务器发起认证请求，SSH服务器对SSH客户端进行认证。SSH支持以下几种认证方式：</p>
<ul>
<li>密码（password）认证：客户端通过用户名和密码的方式进行认证，将加密后的用户名和密码发送给服务器，服务器解密后与本地保存的用户名和密码进行对比，并向客户端返回认证成功或失败的消息。</li>
<li>密钥（publickey）认证：客户端通过用户名、公钥以及公钥算法等信息来与服务器进行认证。</li>
<li>password-publickey认证：指用户需要同时满足密码认证和密钥认证才能登录。</li>
<li>all认证：只要满足密码认证和密钥认证其中一种即可。</li>
</ul>
<p>SSH用户认证最基本的两种方式是密码认证和密钥认证。密码认证的基本原理是SSH客户端使用对称密钥对密码进行加密，SSH服务器使用对称密钥解密后验证密码的合法性，这种认证方式比较简单，且每次登录都需要输入用户名和密码。而密钥认证可以实现安全性更高的免密登录，基本原理是SSH客户端使用客户端私钥对消息进行签名，服务器再使用客户端公钥验证签名，这是一种广泛使用且推荐的登录方式。</p>
<h3 id="3-6-会话请求"><a href="#3-6-会话请求" class="headerlink" title="3.6 会话请求"></a><font size=3>3.6 会话请求</font></h3><p>认证通过后，SSH客户端向服务器发送会话请求，请求服务器提供某种类型的服务，即请求与服务器建立相应的会话。服务器根据客户端请求进行回应。</p>
<h3 id="3-7-会话交互"><a href="#3-7-会话交互" class="headerlink" title="3.7 会话交互"></a><font size=3>3.7 会话交互</font></h3><p>会话建立后，SSH服务器端和客户端在该会话上进行数据信息的交互，双方发送的数据均使用会话密钥进行加解密。</p>
<h2 id="4-SSH端口号是什么？"><a href="#4-SSH端口号是什么？" class="headerlink" title="4. SSH端口号是什么？"></a><font size=3>4. SSH端口号是什么？</font></h2><p>默认情况下，SSH服务器使用端口号22。当SSH应用于<a target="_blank" rel="noopener" href="https://info.support.huawei.com/info-finder/encyclopedia/zh/NETCONF.html">NETCONF</a>时，可以指定默认端口号是22或者830。SSH使用的端口号可以被更改为设备其他可用端口，更改后当前所有的连接都会断开，SSH服务器开始侦听新的端口。由于SSH默认端口号22为知名端口，在进行关键安全传输时，建议修改SSH端口号。</p>
<h2 id="5-ssh工具"><a href="#5-ssh工具" class="headerlink" title="5. ssh工具"></a><font size=3>5. ssh工具</font></h2><p>由于SSH是一套协议标准，需要依赖基于SSH实现的工具完成SSH客户端和SSH服务器之间的连接，PuTTY和OpenSSH应运而生。</p>
<p>PuTTY是Windows上经典的免费SSH连接工具，通常用于使用SSH协议远程登录设备，最新版本可以在<a target="_blank" rel="noopener" href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html">PuTTY官网</a>下载。</p>
<p>OpenSSH是SSH协议的开源实现，支持在Unix操作系统上运行，最新版本可以在<a target="_blank" rel="noopener" href="https://www.openssh.com/">OpenSSH官网</a>下载。目前Windows10已经包含OpenSSH客户端和服务器软件，可在“设置—应用—应用与功能—可选功能”中搜索安装。</p>
<p>我自己常用的就是MobaXterm、SecureCRT和VScode的ssh remote插件等。</p>
<h2 id="6-SSH和SSL的区别"><a href="#6-SSH和SSL的区别" class="headerlink" title="6. SSH和SSL的区别"></a><font size=3>6. SSH和SSL的区别</font></h2><p>SSH和<a target="_blank" rel="noopener" href="https://info.support.huawei.com/info-finder/encyclopedia/zh/SSL.html">SSL</a>都是网络安全协议，通过加密和认证提升两台设备间传输数据的安全性。但SSH和SSL的生效方式和服务目标存在差异。</p>
<p>SSH在两台设备间创建安全隧道，使这两台设备间可以安全地发送命令、传输数据等。例如，客户端通过SSH远程登录到一台服务器上，就可以安全地远程管理这台服务器，在服务器上执行想要的命令。</p>
<p>SSL则是使用SSL证书保证两台设备间安全地传输数据，而不是像SSH那样可以执行命令。例如，用户通过浏览器访问某安装了SSL证书且启用了HTTPS的服务器，浏览器和服务器之间可以安全地传输数据。</p>
<p>SSH就像一辆汽车，我们看不到这辆封闭的汽车里装载的是什么。而SSL就像一个封闭的集装箱，我们可以用不同的交通工具运输它，但看不到集装箱里装的是什么。</p>
<blockquote>
<p>参考资料</p>
<p><a target="_blank" rel="noopener" href="https://info.support.huawei.com/info-finder/encyclopedia/zh/SSH.html">什么是SSH？SSH是如何工作的？ - 华为 (huawei.com)</a></p>
</blockquote>
<h1 id="二、ubuntu中ssh的安装"><a href="#二、ubuntu中ssh的安装" class="headerlink" title="二、ubuntu中ssh的安装"></a><font size=3>二、ubuntu中ssh的安装</font></h1><h2 id="1-检查ssh是否已经安装"><a href="#1-检查ssh是否已经安装" class="headerlink" title="1. 检查ssh是否已经安装"></a><font size=3>1. 检查ssh是否已经安装</font></h2><p>查询是否安装，使用以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo ps -e |grep ssh</span><br></pre></td></tr></table></figure>

<p>查询结果如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901072651457.png" alt="image-20240901072651457" style="zoom:67%;" />

<p>端返回结果中没有 sshd，则说明系统还没有安装 ssh-server 服务，后续对ssh进行安装</p>
<h2 id="2-安装ssh服务"><a href="#2-安装ssh服务" class="headerlink" title="2. 安装ssh服务"></a><font size=3>2. 安装ssh服务</font></h2><p>（1）安装命令</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install openssh-server</span><br></pre></td></tr></table></figure>

<p>安装完毕如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901072817928.png" alt="image-20240901072817928" style="zoom:67%;" />

<p>（2）检查安装情况</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo ps -e |grep ssh</span><br></pre></td></tr></table></figure>

<p>安装完毕后如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901072906728.png" alt="image-20240901072906728" style="zoom:67%;" />

<p>出现了sshd，说明ssh服务已经正常启动了，若安装完毕后，还是没有sshd出现，那么就进行下一步，手动启动ssh服务。</p>
<p>（3）启动 ssh服务</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo /etc/init.d/ssh start </span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073005177.png" alt="image-20240901073005177" style="zoom:67%;" />

<p>运行完毕之后，重新查询ssh服务即可。</p>
<h2 id="3-SSH相关命令"><a href="#3-SSH相关命令" class="headerlink" title="3. SSH相关命令"></a><font size=3>3. SSH相关命令</font></h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">sudo /etc/init.d/ssh stop  # //停止服务</span><br><span class="line">sudo /etc/init.d/ssh start # //启动服务</span><br><span class="line">sudo /etc/init.d/sshresart # //重启服务</span><br><span class="line">exit                       # //断开连接</span><br></pre></td></tr></table></figure>

<h1 id="三、SSH服务的应用"><a href="#三、SSH服务的应用" class="headerlink" title="三、SSH服务的应用"></a><font size=3>三、SSH服务的应用</font></h1><h2 id="1-VScode远程连接ubuntu服务器"><a href="#1-VScode远程连接ubuntu服务器" class="headerlink" title="1. VScode远程连接ubuntu服务器"></a><font size=3>1. VScode远程连接ubuntu服务器</font></h2><p>这个可以查看《02开发工具&#x2F;01VScode&#x2F;LV02-03-连接远程服务器》</p>
<h2 id="2-Windows登录ubuntu服务器"><a href="#2-Windows登录ubuntu服务器" class="headerlink" title="2. Windows登录ubuntu服务器"></a><font size=3>2. Windows登录ubuntu服务器</font></h2><h3 id="2-1-ubuntu配置"><a href="#2-1-ubuntu配置" class="headerlink" title="2.1 ubuntu配置"></a><font size=3>2.1 ubuntu配置</font></h3><p>这里有两种模式，一种是桥接模式，一种是NAT模式。</p>
<h4 id="2-1-1-NAT模式"><a href="#2-1-1-NAT模式" class="headerlink" title="2.1.1 NAT模式"></a><font size=3>2.1.1 NAT模式</font></h4><p>ubuntu可以通过NAT模式借助主机上网，这就意味着我们不需要任何配置，虚拟网卡会自动为ubuntu分配IP地址：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074519334.png" alt="image-20240901074519334" style="zoom:67%;" />

<p>这个IP是可以联网的，可以和windows主机ping通：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074537879.png" alt="image-20240901074537879" style="zoom:50%;" />

<h4 id="2-1-2-桥接模式"><a href="#2-1-2-桥接模式" class="headerlink" title="2.1.2 桥接模式"></a><font size=3>2.1.2 桥接模式</font></h4><p>（1）VMware中虚拟网络编辑器设置如下</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/03105300c9e3eeccdee0b5ecf63dd86d.png" alt="虚拟网络编辑器" style="zoom:86%;" />

<p>（2）虚拟机的网络适配器也需改为桥接模式</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074701252.png" alt="image-20240901074701252" style="zoom: 55%;" />

<h3 id="2-2-Windows配置"><a href="#2-2-Windows配置" class="headerlink" title="2.2 Windows配置"></a><font size=3>2.2 Windows配置</font></h3><h4 id="2-2-1-windows启动ssh服务"><a href="#2-2-1-windows启动ssh服务" class="headerlink" title="2.2.1 windows启动ssh服务"></a><font size=3>2.2.1 windows启动ssh服务</font></h4><ul>
<li>【设置】&rarr;【应用】&rarr;【可选功能】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073543765.png" alt="image-20240901073543765" style="zoom: 33%;" />

<ul>
<li>查看一下是否安装SSH相关服务，没有任何显示表示什么都没装，显示卸载表示已安装</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073706572.png" alt="image-20240901073706572" style="zoom:33%;" />

<p>这里一般来说服务器和客户端都需要安装。</p>
<ul>
<li>【添加可选功能】&rarr;【搜索SSH服务器】&rarr;【勾选】&rarr;【下一步】&rarr;【安装】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901073934709.png" alt="image-20240901073934709" style="zoom:33%;" />

<p>安装界面如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074121752.png" alt="image-20240901074121752" style="zoom:33%;" />

<p>等待安装完成即可。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075230710.png" alt="image-20240901075230710" style="zoom: 33%;" />

<h4 id="2-2-2-与ubuntu的ip互ping"><a href="#2-2-2-与ubuntu的ip互ping" class="headerlink" title="2.2.2  与ubuntu的ip互ping"></a><font size=3>2.2.2  与ubuntu的ip互ping</font></h4><p>要保证windows可以ping通ubuntu：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ping ip-address</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074537879.png" alt="image-20240901074537879" style="zoom:50%;" />

<h4 id="2-2-3-登录Ubuntu"><a href="#2-2-3-登录Ubuntu" class="headerlink" title="2.2.3 登录Ubuntu"></a><font size=3>2.2.3 登录Ubuntu</font></h4><ul>
<li>（1）登录命令</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh user-name@ip-address</span><br></pre></td></tr></table></figure>

<p>如：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh sumu@192.168.19.137</span><br></pre></td></tr></table></figure>

<ul>
<li>（2）首次登录会出现如下提示，输入用户密码即可。</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075434084.png" alt="image-20240901075434084" style="zoom: 48%;" />

<ul>
<li>（3）登录成功如下图</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075346249.png" alt="image-20240901075346249" style="zoom:48%;" />

<h2 id="2-3-MobaXterm登录ubuntu服务器"><a href="#2-3-MobaXterm登录ubuntu服务器" class="headerlink" title="2.3 MobaXterm登录ubuntu服务器"></a><font size=3>2.3 MobaXterm登录ubuntu服务器</font></h2><p>这里需要注意，运行MobaXterm的主机要可以和ubuntu服务器ping通。</p>
<h4 id="2-3-1-查看ubuntu的IP"><a href="#2-3-1-查看ubuntu的IP" class="headerlink" title="2.3.1 查看ubuntu的IP"></a><font size=3>2.3.1 查看ubuntu的IP</font></h4><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901074519334.png" alt="image-20240901074519334" style="zoom:67%;" />

<h4 id="2-3-2-连接ubuntu"><a href="#2-3-2-连接ubuntu" class="headerlink" title="2.3.2 连接ubuntu"></a><font size=3>2.3.2 连接ubuntu</font></h4><ul>
<li>【Session】&rarr;【SSH】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901075812169.png" alt="image-20240901075812169" style="zoom:48%;" />

<ul>
<li>输入主机IP即可，端口选择22，然后确认</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901080006762.png" alt="image-20240901080006762" style="zoom:50%;" />

<ul>
<li>点击完Accept，显示让输入用户名和密码，输入ubuntu的用户名和登录密码即可。</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901080113043.png" alt="image-20240901080113043" style="zoom:50%;" />

<p>输入完成后会提示是否需要保存密码，这个可以保存也可以不保存，保存的哈下次只需要敲回车，就会自动填充用户名和密码并登录。</p>
<ul>
<li>登录成功如下图</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/04Ubuntu/LV02-ubuntu-SSH%E7%9A%84%E4%BD%BF%E7%94%A8/img/image-20240901080336783.png" alt="image-20240901080336783" style="zoom:50%;" />

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/a3f1cf94.html">LV02-ubuntu-SSH的使用</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年09月01日 - 08:32</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/a3f1cf94.html" title="LV02-ubuntu-SSH的使用">https://sumumm.github.io/post/a3f1cf94.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/ubuntu/" rel="tag"><i class="fa fa-tag"></i> ubuntu</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/a93edde0.html" rel="prev" title="LV01-02-IMX6ULL-ALPHA开发板体验-06-挂载ubuntu目录">
                  <i class="fa fa-angle-left"></i> LV01-02-IMX6ULL-ALPHA开发板体验-06-挂载ubuntu目录
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/904cb7c1.html" rel="next" title="LV01-SOFT-05-ubuntu网络图标问题">
                  LV01-SOFT-05-ubuntu网络图标问题 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
